<?php


namespace app\api\controller;


use app\api\BaseController;
use think\facade\Db;

class Picture extends BaseController
{
/**
--
-- 表的结构 `picture`
--

CREATE TABLE `picture` (
  `picture_id` int(11) NOT NULL,
  `picture_url` text NOT NULL,
  `picture_info` text NOT NULL,
  `picture_time` datetime NOT NULL
) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4;

--
-- 转存表中的数据 `picture`
--

INSERT INTO `picture` (`picture_id`, `picture_url`, `picture_info`, `picture_time`) VALUES
(1, 'http://3040410.yyuebd.com/storage/uploads/20230404/c86f4b6fc0f29ef276ca5195d807d35a.png', '地点1', '2023-04-04 16:28:28'),
(2, 'http://3040410.yyuebd.com/storage/uploads/20230404/9a08c2fdf5d73ffde02d962d9259a2db.jpg', '地点2', '2023-04-04 16:28:17'),
(3, 'http://3040410.yyuebd.com/storage/uploads/20230404/81b66c365abfb739bc0bd3b23a00bb98.jpg', '地点3', '2023-04-04 16:28:37');

--
-- 转储表的索引
--

--
-- 表的索引 `picture`
--
ALTER TABLE `picture`
  ADD PRIMARY KEY (`picture_id`);

--
-- 在导出的表使用AUTO_INCREMENT
--

--
-- 使用表AUTO_INCREMENT `picture`
--
ALTER TABLE `picture`
  MODIFY `picture_id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=4;
COMMIT;
**/
    protected $table = 'picture';
    public function getPicture(){
        $data = request()->param();
        $page = (int)$data['page'];
        $limit = (int)$data['limit'];
        $result2 = [];
        $result2['del_status'] = ['=',0];
        $result2['picture_info'] = ['like',empty($data['picture_info'])?'':'%'.$data['picture_info'].'%'];
        $this->getData($this->table,$page,$limit,$result2);
    }
    public function uploadPicture(){
        $size = 1048576;
        $fileType = "jpg,jpeg,png,gif,bmp";
        $sc = fileUpload($size,$fileType);
        return json($sc);
    }
    public function addPicture(){
        $data = request()->param();
        $data['picture_time'] = date("Y-m-d H:i:s");
        $this->addData($this->table,$data);
    }
    public function updatePicture(){
        $data = request()->param();
        $data['picture_time'] = date("Y-m-d H:i:s");
        $this->updateData($this->table,['picture_id'=>$data['picture_id']],$data,'修改');
    }
    public function delPicture(){
        $data = request()->param();
        $this->delData($this->table,['picture_id'=>$data['picture_id']],'picture_url',true);
    }	
}